/**
 * @Author: 赵京涛 z19472333952022@163.com
 * @Date: 2025-09-12 15:57:04
 * @LastEditors: 赵京涛 z19472333952022@163.com
 * @LastEditTime: 2025-09-12 15:57:04
 * @projectName: HeBeiHaiYangData
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki
 */
import type {
  RouteLocationNormalized,
  RouteLocationNormalizedLoaded,
  RouteRecordRaw,
} from "vue-router";
import { createRouter, createWebHashHistory } from "vue-router";
import type {
  _ScrollPositionNormalized,
  AppRouteRecordRaw,
  Awaitable,
  ScrollPosition,
} from "@/types/routerTypes";
import { baseRouter } from "@/router/baseRouter";

export const constantRoutes: AppRouteRecordRaw[] = baseRouter;
export const dynamicRoutes: AppRouteRecordRaw[] = [];
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  scrollBehavior(
    to: RouteLocationNormalized,
    _from: RouteLocationNormalizedLoaded,
    savedPosition: _ScrollPositionNormalized | null,
  ): Awaitable<ScrollPosition | false | void> {
    if (savedPosition) {
      return savedPosition;
    }
    if (to.hash) {
      return {
        el: to.hash,
        behavior: "smooth",
      };
    }
    return { top: 0 };
  },
});
export default router;
